#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<vector<string>> groupAnagrams(vector<string>& strs) {
        int n = strs.size();
        unordered_map<string, vector<string>> hash;
        for (int i = 0; i < n; i++) {
            string tmp = strs[i];
            sort(tmp.begin(), tmp.end());
            hash[tmp].push_back(strs[i]);
        }
        vector<vector<string>> ret;
        for (auto& [left, right] : hash) {
            ret.push_back(right);
        }
        return ret;
    }
};
